
var Utility = require("../Utility/utility.js");
var Action = require("../apiaction");
exports.userRouter = function(router){


    //用户列表
    router.all('/user/userlist',function(req,res){


        Utility.getMenuList(req,res,function(menulist) {
            res.render('user/userlist', {
                layout: 'pte/layout-pte',
                active: 'userlist',
                jscript: 'user/user',
                menulist:menulist,
                comparam:Utility.returnCommonParam(req,res)
            })

        });

    });

    //轮播图

    /*
    *
    */
    router.all('/worker/usercarolsellist',function(req,res){


            Utility.getMenuList(req,res,function(menulist) {
                res.render('user/usercarolsellist', {
                    layout: 'pte/layout-pte',
                    active: 'usercarolsellist',
                    jscript: 'user/usercarolsellist',
                    menulist:menulist,
                    comparam:Utility.returnCommonParam(req,res)
                })

            });

        });


    /*
    *  用户案例
    */
    router.all('/user/usercaselist',function(req,res){


            Utility.getMenuList(req,res,function(menulist) {
                res.render('user/usercaselist', {
                    layout: 'pte/layout-pte',
                    active: 'usercaselist',
                    jscript: 'user/usercaselist',
                    menulist:menulist,
                    comparam:Utility.returnCommonParam(req,res)
                })

            });

        });


    /*
    *效果图种类
    */
    router.all('/user/userpreviewkindlist',function(req,res){


            Utility.getMenuList(req,res,function(menulist) {
                res.render('user/userpreviewkindlist', {
                    layout: 'pte/layout-pte',
                    active: 'userpreviewkindlist',
                    jscript: 'user/userpreviewkindlist',
                    menulist:menulist,
                    comparam:Utility.returnCommonParam(req,res)
                })

            });

        });


    /*
     *效果图列表
     */
    router.all('/user/userpreviewlist',function(req,res){


        Utility.getMenuList(req,res,function(menulist) {
            res.render('user/userpreviewlist', {
                layout: 'pte/layout-pte',
                active: 'userpreviewlist',
                jscript: 'user/userpreviewlist',
                menulist:menulist,
                comparam:Utility.returnCommonParam(req,res)
            })

        });

    });


    /*
     * 提现列表
     */
    router.all('/user/ucwithdrawlist',function(req,res){


        Utility.getMenuList(req,res,function(menulist) {
            res.render('user/ucwithdrawlist', {
                layout: 'pte/layout-pte',
                active: 'ucwithdrawlist',
                jscript: 'user/ucwithdrawlist',
                menulist:menulist,
                comparam:Utility.returnCommonParam(req,res)
            })

        });

    });


    /*
    *
    */

    router.all(['/jf/addinfo'],function(req,res){



                res.render('jf/addinfo', {
                    layout: 'jf/layout-jf',
                    active: 'addinfo',
                    jscript: 'jf/addinfo',
                    comparam:Utility.returnCommonParam(req,res)
                })



        });


    //列表获取
    router.all('/user/GetListPaging', function (req, res) {

        var params = {worker_id: req.param("worker_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/GetListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/user/addWeight', function (req, res) {

        var params = {user_id: req.param("user_id"),weight: req.param("weight"),record_day: req.param("record_day")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/addWeight", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    /*
    *
    */
    router.all(['/jf/viewinfo'],function(req,res){



                res.render('jf/viewinfo', {
                    layout: 'jf/layout-jf',
                    active: '',
                    jscript: 'jf/viewinfo',

                    comparam:Utility.returnCommonParam(req,res)
                })



        });


    router.all(['/','/login','/jf/newinfo'],function(req,res){




        var params = {};


        Action.send(req, res, "/user/getNewWeightList", params, function (res, data) {

            var json = JSON.parse(data);
            var list = json.data;

            var l = list[0].weight_list.length+2;

            var w= l*60;


            res.render('jf/newinfo', {
                layout: 'jf/layout-jf',
                active: '',
                jscript: 'jf/newinfo',
                list:list,
                w:w,

                comparam:Utility.returnCommonParam(req,res)
            })


        });






    });


    //列表获取
    router.all('/user/getWeightListPaging', function (req, res) {

        var params = {user_id: req.param("user_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/getWeightListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });





}
